home *** CD-ROM | disk | FTP | other *** search
- Subject: Re:Coercion Woes
- Sent: 6/24/96 10:24 AM
- Received: 6/24/96 10:45 AM
- From: Greg Friedman, friedman@cognosis.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- At 12:09 AM 6/24/96, Hutchings Software Development wrote:
-
- > OK, so I installed my own coercion function using FW_CSemanticInterface.
- > Then, within my code, I call:
- >
- > result_desc.CoerceInPlace(kClass_RIPoint);
- >
- > where result_desc is a FW_CDesc representing a perfectly good descriptor
- > obtained from ::OSACoerceToDesc (I've walked through that code and know it
- > works), and kClass_RIPoint is an AppleScript class defined in my 'aete'.
- >
- > Problem is, my coercion handler does not get called. So, I stepped through
- > the debug version of OpenDoc 1.0.4 into
- > ODMessageInterface::HandleAllCoercionsAux, where I found the line:
- >
- > ODPart* contextPart = _fNameResolver->GetCurrentContextPart(ev);
- >
- > And sure enough, context_part == kODNULL after stepping over it.
- > Unfortunately, there are no public methods for setting the current context
- > part.
-
- I suspect you may be the first OpenDoc user to attept to invoke a custom
- coercion handler after object resolution. I can believe that this hasn't
- been tested, and may not work. Unfortunately, the OpenDoc fix might not be
- trivial. The problem is that the message interface can be invoked at any
- time by a part, and the message interface doesn't have any way of knowing
- what the current context should be.
-
- > So, I guess there are two problems/questions here...
- >
- > (1) Should OpenDoc provide support for parts which want to use the
- > Apple Event Manager to do coersions when the part is not involved
- > in OSL protocol?
-
- I'd like to say "yes", but I'm not sure it's possible without some
- significant modifications.
-
- >
- > (2) With ODF, should FW_CDesc::CoerceInPlace optionally take a
- > FW_CSemanticInterface parameter so in-part coercions can be
- > dispatched directly? Or should I just be calling my coercion
- > proc directly (which actually looks like a good idea now that
- > I've typed up my problem!)?
-
- This is the right idea, but it breaks encapsulation significantly.
- Currently, FW_CDesc has no knowledge of parts or semantic interfaces. It's
- going to stay that way. At some point, I want to push FW_CDesc down into
- the OS layer where it belongs. It shouldn't be in the framework layer. For
- this to happen, FW_CDesc can't be dependent on parts or semantic
- interfaces.
-
- If we were developing applications, I would rearchitect things so that
- FW_CDesc owned coercion handlers. This would probably be implemented as a
- singleton. The problem is that singletons don't work in the OpenDoc world,
- because they require part-specific globals (not editor-specific globals).
-
- I'll think about this, and come up with a solution that works.
-
- In the meantime, you might want to call your semantic interface's coercion
- method directly.
-
- BTW: Why are you declaring a new "point" class, and not using the point
- class defined in the AppleEvent Registry? In addition to the coercion
- problem you are having now, you're going to have a problem with comparison
- operators during the resolution of whose clauses. Currently, there is no
- way to extend the set of comparison handlers invoked by FW_CDesc. The
- architectural problem is the same as the problem that exists for coercion
- handlers. When possible, you should really use the AppleEvent Registry
- classes, since they are supported by AppleScript and by ODF.
-
- gsf.
-
-
- _________________________________________________________
- Greg Friedman ODF Engineering Apple Computer
-
-